package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.DailyTags;
import com.ruoyi.ring.service.IDailyTagsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 事件小计
 * 
 * @author liuwp
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/ring/daily_tags")
public class DailyTagsController extends BaseController
{
    @Resource
    private IDailyTagsService dailyTagsService;

    /**
     * 查询事件小计列表
     */
    @PreAuthorize("@ss.hasPermi('ring:daily_tags:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailyTags dailyTags)
    {
        startPage();
        List<DailyTags> list = dailyTagsService.selectDailyTagsList(dailyTags);
        return getDataTable(list);
    }

    /**
     * 导出事件小计列表
     */
    @PreAuthorize("@ss.hasPermi('ring:daily_tags:export')")
    @Log(title = "事件小计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailyTags dailyTags)
    {
        List<DailyTags> list = dailyTagsService.selectDailyTagsList(dailyTags);
        ExcelUtil<DailyTags> util = new ExcelUtil<DailyTags>(DailyTags.class);
        util.exportExcel(response, list, "事件小计数据");
    }

    /**
     * 获取事件小计详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:daily_tags:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dailyTagsService.selectDailyTagsById(id));
    }

    /**
     * 新增事件小计
     */
    @PreAuthorize("@ss.hasPermi('ring:daily_tags:add')")
    @Log(title = "事件小计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailyTags dailyTags)
    {
        return toAjax(dailyTagsService.insertDailyTags(dailyTags));
    }

    /**
     * 修改事件小计
     */
    @PreAuthorize("@ss.hasPermi('ring:daily_tags:edit')")
    @Log(title = "事件小计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailyTags dailyTags)
    {
        return toAjax(dailyTagsService.updateDailyTags(dailyTags));
    }

    /**
     * 删除事件小计
     */
    @PreAuthorize("@ss.hasPermi('ring:daily_tags:remove')")
    @Log(title = "事件小计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dailyTagsService.deleteDailyTagsByIds(ids));
    }

}
